#include "StdAfx.h"
#include "BaseStrategy.h"

using namespace SmartTrade;

BaseStrategy::BaseStrategy(void){
	pTransactionVector_ = new vector<Ptr_Transaction>();
	pContext_ = NULL;
}


BaseStrategy::~BaseStrategy(void){
}
void BaseStrategy::SetContext(Ptr_Context pContext){
	if(pContext != NULL && pContext)
		pContext_ = pContext;
}
void BaseStrategy::RegisterBarInfo(const char* pInstrumentId,SmartTradecBarTypeEnum enumBarType,long lBarSize){
	if(pContext_ != NULL)
		pContext_->RegisterBarInfo(pInstrumentId,enumBarType,lBarSize);
}

void BaseStrategy::SubscribeInstrument(const char* pInstrumentIds){
	if(pContext_ != NULL)
		pContext_->SubscribeInstrument(pInstrumentIds);
}
void BaseStrategy::SubscribePairInstrument(const char* pFirstInstrumentId,const char* pSecondInstrumentId){
	if(pContext_ != NULL)
		pContext_->SubscribePairInstrument(pFirstInstrumentId,pSecondInstrumentId);
}

Ptr_Transaction BaseStrategy::CreateTransaction(const string& strInstId,
	const double dPrice,const int iQty,const SmartTradecTransationSideEnum enumSide){
	Ptr_Transaction pTrans =  new SmartTradecTransaction();
	strcpy(pTrans->InstrumentId , strInstId.c_str());
	pTrans->Price = dPrice;
	pTrans->Qty = iQty;
	pTrans->Side = enumSide;
	pTrans->Id = GetTransactionId();
	return pTrans;
}

void SendTransaction(Ptr_Transaction pTrans){
	
}
void SendArbitTransaction(int iSignal,Ptr_Transaction pFirstTrans,Ptr_Transaction pSecondTrans){
	Ptr_ArbitTransaction pArbitTrans = new SmartTradecArbitTransaction();
	pArbitTrans->FirstTransaction = GetImpl(pFirstTrans);
	pArbitTrans->SecondTransaction = GetImpl(pSecondTrans);
	pArbitTrans->Signal = iSignal;
}

void BaseStrategy::StartStrategy(){}
void BaseStrategy::StopStrategy(){}

void BaseStrategy::On_Quote(SmartTradecQuoteInstrument* pQuote){}
void BaseStrategy::On_Trade(SmartTradecTradeInstrument* pTrade){}
void BaseStrategy::On_Bar(SmartTradecBarInstrument* pBar){}
void BaseStrategy::On_DepthMarketData(SmartTradecDepthMarketData* pDepthMarketData){}
void BaseStrategy::On_PairQuote(SmartTradecPairQuoteData* pPairQuote){}
void BaseStrategy::On_PairTrade(SmartTradecPairTradeData* pPairTrade){}
void BaseStrategy::On_PairCloseBar(SmartTradecPairBarData* pPairBar){}
void BaseStrategy::On_PairDepthMarketData(SmartTradecPairDepthMarketData* pPairDepthMarketData){}

int BaseStrategy::I_TRANSACTION_ID = 0;